package org.yagnus.langutils.mutables;

public final class MutableLong {
	long v;

	public final long apply() {
		return v;
	}

	public final long get() {
		return v;
	}

	public final long inc() {
		return (v += 1);
	}

	public final long dec() {
		return (v -= 1);
	}

	public final long inc(long d) {
		return (v += d);
	}

	public final long dec(long d) {
		return (v -= d);
	}

	@Override
	public final String toString() {
		return "MutableLong [v=" + v + "]";
	}

	@Override
	public final int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (v ^ (v >>> 32));
		return result;
	}

	@Override
	public final boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MutableLong other = (MutableLong) obj;
		if (v != other.v)
			return false;
		return true;
	}

	public MutableLong(long v) {
		super();
		this.v = v;
	}

	public final long longValue() {
		return v;
	}

	public final int intValue() {
		return (int) v;
	}

	public final float floatValue() {
		return (float) v;
	}

	public final double doubleValue() {
		return (double) v;
	}
}
